home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / sstream.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  9.8 KB  |  293 lines

  1. #ifndef __STD_SSTREAM__
  2. #define __STD_SSTREAM__
  3. #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * sstream - Declarations for the Standard Library basic streams
  8.  *
  9.  * $Id: sstream,v 1.42 1996/09/24 19:18:19 smithey Exp $
  10.  *
  11.  ***************************************************************************
  12.  *
  13.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  14.  * ALL RIGHTS RESERVED *
  15.  * The software and information contained herein are proprietary to, and
  16.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  17.  * intends to preserve as trade secrets such software and information.
  18.  * This software is furnished pursuant to a written license agreement and
  19.  * may be used, copied, transmitted, and stored only in accordance with
  20.  * the terms of such license and with the inclusion of the above copyright
  21.  * notice.  This software and information or any other copies thereof may
  22.  * not be provided or otherwise made available to any other person.
  23.  *
  24.  * Notwithstanding any other lease or license that may pertain to, or
  25.  * accompany the delivery of, this computer software and information, the
  26.  * rights of the Government regarding its use, reproduction and disclosure
  27.  * are as set forth in Section 52.227-19 of the FARS Computer
  28.  * Software-Restricted Rights clause.
  29.  * 
  30.  * Use, duplication, or disclosure by the Government is subject to
  31.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  32.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  33.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  34.  * P.O. Box 2328, Corvallis, Oregon 97339.
  35.  *
  36.  * This computer software and information is distributed with "restricted
  37.  * rights."  Use, duplication or disclosure is subject to restrictions as
  38.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  39.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  40.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  41.  * then the "Alternate III" clause applies.
  42.  *
  43.  **************************************************************************/
  44.  
  45. #include <streambuf>
  46. #include <istream>
  47. #include <ostream>
  48.  
  49. #ifndef _RWSTD_NO_NAMESPACE
  50. namespace std{
  51. #endif
  52.   
  53. template<class charT, class traits, class Allocator>
  54. class _RWSTDExportTemplate basic_stringbuf : public basic_streambuf<charT, traits> {
  55.  
  56.   public:
  57.     typedef basic_ios<charT, traits>                 ios_type;
  58.     typedef basic_string<charT, traits, Allocator >  string_type;
  59.  
  60.     typedef traits                              traits_type;
  61.     typedef charT                           char_type;
  62.     typedef _TYPENAME traits::int_type           int_type;
  63.     typedef _TYPENAME traits::pos_type           pos_type;
  64.     typedef _TYPENAME traits::off_type           off_type;
  65.  
  66.  
  67.     _EXPLICIT basic_stringbuf(ios_base::openmode which = 
  68.                              ios_base::in | ios_base::out );
  69.      
  70.     _EXPLICIT basic_stringbuf(const string_type& str,
  71.                              ios_base::openmode which = 
  72.                              ios_base::in | ios_base::out );
  73.     
  74.     virtual ~basic_stringbuf();
  75.      
  76.  
  77.  
  78.     string_type str() const;
  79.      
  80.  
  81.     void str(const string_type& str_arg);
  82.  
  83.  
  84.   protected:
  85.  
  86.     virtual int_type overflow(int_type c = traits::eof());
  87.  
  88.     virtual int_type pbackfail(int_type c = traits::eof());
  89.  
  90.     virtual int_type underflow();
  91.  
  92.     virtual pos_type seekoff(off_type off, ios_base::seekdir way,
  93.                              ios_base::openmode which =
  94.                              ios_base::in | ios_base::out);
  95.  
  96.     virtual pos_type seekpos(pos_type sp,
  97.                              ios_base::openmode which =
  98.                              ios_base::in | ios_base::out);
  99.  
  100.     virtual basic_streambuf<charT,traits>* setbuf(char_type* s, streamsize n);
  101.  
  102.     virtual streamsize xsputn(const char_type *s, streamsize n);
  103.  
  104.   private:
  105.  
  106.     charT                   *data_;
  107.     streamsize              length_;
  108.     streamsize              end_pos;
  109.     
  110. };
  111.  
  112.  
  113. template<class charT, class traits, class Allocator>
  114. class _RWSTDExportTemplate basic_istringstream : public basic_istream<charT, traits> {
  115.  
  116.   public:
  117.  
  118.     typedef basic_stringbuf<charT, traits, Allocator>      sb_type;
  119.     typedef basic_ios<charT, traits>                       ios_type;
  120.     typedef basic_string<charT, traits, Allocator >        string_type;
  121.  
  122.     typedef traits                                         traits_type;
  123.     typedef charT                                       char_type;
  124.     typedef _TYPENAME traits::int_type                      int_type;
  125.     typedef _TYPENAME traits::pos_type                      pos_type;
  126.     typedef _TYPENAME traits::off_type                      off_type;
  127.  
  128.     _EXPLICIT basic_istringstream(ios_base::openmode which = ios_base::in);
  129.     _EXPLICIT basic_istringstream(const string_type& str,
  130.                                  ios_base::openmode which = ios_base::in);
  131.  
  132.     virtual ~basic_istringstream();
  133.  
  134.     basic_stringbuf<charT, traits, Allocator> *rdbuf() const;
  135.     string_type str() const;
  136.  
  137.     void str(const string_type& str);
  138.  
  139.   protected:
  140.  
  141.   private:
  142.  
  143.   basic_stringbuf<charT, traits, Allocator>    sb_;
  144.  
  145. };
  146.  
  147.  
  148. template<class charT, class traits, class Allocator>
  149. class _RWSTDExportTemplate basic_ostringstream : public basic_ostream<charT, traits> {
  150.  
  151.  public:
  152.  
  153.     typedef basic_stringbuf<charT, traits, Allocator>        sb_type;
  154.     typedef basic_ios<charT, traits>                         ios_type;
  155.     typedef basic_string<charT, traits, Allocator>           string_type;
  156.  
  157.     typedef traits                                           traits_type;
  158.     typedef charT                                           char_type;
  159.     typedef _TYPENAME traits::int_type                        int_type;
  160.     typedef _TYPENAME traits::pos_type                        pos_type;
  161.     typedef _TYPENAME traits::off_type                        off_type;
  162.  
  163.     _EXPLICIT basic_ostringstream(ios_base::openmode which = ios_base::out);
  164.     _EXPLICIT basic_ostringstream(const string_type& str,
  165.                                  ios_base::openmode which = ios_base::out);
  166.  
  167.     virtual ~basic_ostringstream();
  168.  
  169.     basic_stringbuf<charT, traits, Allocator> *rdbuf() const;
  170.     string_type str() const;
  171.  
  172.     void str(const string_type& str);
  173.  
  174.   protected:
  175.  
  176.   private:
  177.  
  178.     sb_type            sb_;
  179.  
  180. };
  181.  
  182.  
  183. /*
  184.  *
  185.  *  Class stringstream
  186.  *
  187.  */
  188.  
  189. template<class charT, class traits, class Allocator>
  190. class _RWSTDExportTemplate basic_stringstream : public basic_iostream<charT, traits> {
  191.  
  192.   public:
  193.  
  194.     typedef basic_stringbuf<charT, traits, Allocator>        sb_type;
  195.     typedef basic_ios<charT, traits>                         ios_type;
  196.     typedef basic_string<charT, traits, Allocator>           string_type;
  197.  
  198.     typedef traits                                           traits_type;
  199.     typedef charT                                           char_type;
  200.     typedef _TYPENAME traits::int_type                        int_type;
  201.     typedef _TYPENAME traits::pos_type                        pos_type;
  202.     typedef _TYPENAME traits::off_type                        off_type;
  203.  
  204.     _EXPLICIT basic_stringstream(ios_base::openmode which = ios_base::out | 
  205.                                 ios_base::in);
  206.  
  207.     _EXPLICIT basic_stringstream(const string_type& str,
  208.                                 ios_base::openmode which = 
  209.                                 ios_base::out | ios_base::in);
  210.  
  211.     virtual ~basic_stringstream();
  212.  
  213.     basic_stringbuf<charT, traits, Allocator> *rdbuf() const;
  214.     string_type str() const;
  215.  
  216.     void str(const string_type& str);
  217.  
  218.   protected:
  219.  
  220.   private:
  221.  
  222.     sb_type            sb_;
  223.  
  224. };
  225.  
  226.  
  227. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  228. typedef basic_stringbuf<char>                            stringbuf;
  229. #else
  230. typedef basic_stringbuf<char, char_traits<char>, allocator<char> > stringbuf;
  231. #endif
  232. #ifndef _RWSTD_NO_WIDE_CHAR
  233. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  234. typedef basic_stringbuf<wchar_t>                         wstringbuf;
  235. #else
  236. typedef basic_stringbuf<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstringbuf;
  237. #endif
  238. #endif
  239.  
  240. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  241. typedef basic_istringstream<char>                        istringstream;
  242. #else
  243. typedef basic_istringstream<char, char_traits<char>, allocator<char> > istringstream;
  244. #endif
  245. #ifndef _RWSTD_NO_WIDE_CHAR
  246. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  247. typedef basic_istringstream<wchar_t>                     wistringstream;
  248. #else
  249. typedef basic_istringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wistringstream;
  250. #endif
  251. #endif
  252.  
  253.  
  254. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  255. typedef basic_ostringstream<char>                        ostringstream;
  256. #else
  257. typedef basic_ostringstream<char, char_traits<char>, allocator<char> >    ostringstream;
  258. #endif
  259. #ifndef _RWSTD_NO_WIDE_CHAR
  260. #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
  261. typedef basic_ostringstream<wchar_t>                     wostringstream;
  262. #else
  263. typedef basic_ostringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wostringstream;
  264. #endif
  265. #endif
  266.  
  267. #ifndef _RWSTD_NO_DEFAULT_TEMPLATES
  268. typedef basic_stringstream<char>                      stringstream;
  269. #else
  270. typedef basic_stringstream<char, char_traits<char>, allocator<char> >   stringstream;
  271. #endif
  272.  
  273. #ifndef _RWSTD_NO_WIDE_CHAR
  274. #ifndef _RWSTD_NO_DEFAULT_TEMPLATES
  275. typedef basic_stringstream<wchar_t>                        wstringstream;
  276. #else
  277. typedef basic_stringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >  wstringstream;
  278. #endif
  279. #endif
  280.  
  281.  
  282. #ifndef _RWSTD_NO_NAMESPACE
  283. }
  284. #endif
  285.  
  286.  
  287. #ifdef _RWSTD_COMPILE_INSTANTIATE
  288. #include <sstream.cc>
  289. #endif
  290.  
  291. #pragma option pop
  292. #endif /* __SSTREAM__ */
  293.